﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" />
<title>离校登记</title>
</head>
	<body>
		<div class="con">
		  <div class="head">
			<div class="logo"> <a href="index.jsp"> <img src="images/logo.png" /></a> </div>
			<div class="nav">
			  <ul>
				<li id="cur"><a href="#"><%out.print((String)application.getAttribute("name"));%></a></li>
			  </ul>
			</div>
			<div class="clear"></div>
		  </div>
		</div>
		
		<%
		String user=(String)session.getValue("myuser");
		if(user==null){ 
			response.sendRedirect("login.html");
		}
		
		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); 
		String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=STU_LEAVE_INFO";
		String sqlUser = "web";
		String sqlPwd = "prog";
		Connection conn = DriverManager.getConnection(url,sqlUser,sqlPwd);
		Statement stmt = conn.createStatement();
		String sql="SELECT S.STU_ID,STU_NAME,MAJ_NAME,CLASS,LEAVE_TIME,BACK_TIME,DESTINATION,STU_TEL,PARENT_NAME,PARENT_TEL FROM T_STUDENT S,T_MAJOR M,T_LEAVE_INFO L WHERE S.STU_ID = M.STU_ID AND S.STU_ID = L.STU_ID"; 
		ResultSet rs=stmt.executeQuery(sql);
		
		String exportToExcel = request.getParameter("exportToExcel");
		if (exportToExcel != null&& exportToExcel.toString().equalsIgnoreCase("YES")) {
			response.setContentType("application/vnd.ms-excel");
			response.setHeader("Content-Disposition", "inline; filename="+ "excel.xls");
		}%>
		
		<table border="1" width="42%" id="table1">
			<caption><h2>学生离校登记情况</h2></caption>
			<tr><th width="82">学号</th>
				<th width="82">姓名</th>
				<th width="82">专业</th>
				<th width="82">班级</th>
				<th width="83">离校时间</th>
				<th width="82">返校时间</th>
				<th width="82">目的地</th>
				<th width="82">学生手机号码</th>
				<th width="82">家属姓名</th>
				<th width="82">家属联系方式</th>
			</tr>
		<%
		//下面通过循环把字段的内容显示出来
		 while(rs.next()) {%>
			<tr><td width="82"><%=rs.getString(1)%></td>
				<td width="83"><%=rs.getString(2)%></td>
				<td width="83"><%=rs.getString(3)%></td>
				<td width="83"><%=rs.getString(4)%></td>
				<td width="83"><%=rs.getString(5)%></td>
				<td width="82"><%=rs.getString(6)%></td>
				<td width="82"><%=rs.getString(7)%></td>
				<td width="82"><%=rs.getString(8)%></td>
				<td width="82"><%=rs.getString(9)%></td>
				<td width="82"><%=rs.getString(10)%></td>
			</tr>
		<%}%> 
		</table>
		<%
			rs.close(); 
			stmt.close(); 
			conn.close(); 
		%>
		<div class="clear"></div>
		
		<div class="sub"> <a href="report.jsp?exportToExcel=YES"><input type="submit" value="生成Excel表格" style="width:150px;height:30px;" /></a></div>
		<div class="clear"></div>
		
		<div class="foot">
		  <p><a href="#">集美大学官网</a><span> |</span> <a href="#">关于我们</a></p>
		</div>
		<div class="clear"></div>
	</body>
</html>